package Template.interfacesImpl;

import Template.interfaces.CaffeineBeverage;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Author: pengzx
 * @Description:
 * @Date: 9:48 2017/9/18
 * @Modified by: 1.0
 */
public class CoffeeWithHook extends CaffeineBeverage {
    @Override
    public void brew()
    {
        System.out.println("过滤咖啡...");
    }

    @Override
    public void addCondiments()
    {
        System.out.println("加入糖和牛奶...");
    }

    @Override
    public boolean customerWantsCondiments()
    {
        String ans = getUserInput();
        if (ans.toLowerCase().equals("y")){
            return true;
        }else{
            return false;
        }
    }

    private String getUserInput(){
        String answer = null;

        System.out.println("是否需要加入配料...（y/n）");

        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

        try {
            answer = bufferedReader.readLine();
        } catch (IOException e) {
            System.out.println("不知道你要啥...");
            e.printStackTrace();
        }
        if (answer == null){
            return "no";
        }
        return answer;
    }
}
